import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/assets/reset.css'
import '@/assets/border.css'
import common from './components/common.js'
Vue.config.productionTip = false
router.beforeEach((to, from,next) => {
  function edit_menu_active(){//点击二级菜单  高亮所属的一级菜单
    let menu = store.state.menu//获取vueX 下的菜单
    let submenu = ''
    for(let item in menu){
      if(to.path.split('/')[1]  == menu[item].path.split('/')[1]){
        menu[item].active = true
        if(menu[item].children){
          submenu = menu[item].children
          console.log(store.state.submenu)
        }
      }else{
        menu[item].active = false
      }
    }
    store.state.menu = menu //修改后的菜单 写入vueX
    store.state.submenu = submenu //子菜单 写入vueX
    
  }edit_menu_active()
  next()
})
Vue.prototype.common = common
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
